package cn.assumejson.springframework.aop.framework.autoproxy;

import cn.assumejson.springframework.aop.Pointcut;
import cn.assumejson.springframework.aop.PointcutAdvisor;
import cn.hutool.core.lang.Assert;
import org.aopalliance.aop.Advice;

/**
 * @author gang.Li
 * @version 1.0
 * @since 1.0 2021/12/9 15:55
 */
public class AspectJPointcutAdvisor implements PointcutAdvisor {
    private final AbstractAspectJAdvice advice;

    private final Pointcut pointcut;

    public AspectJPointcutAdvisor(AbstractAspectJAdvice advice) {
        Assert.notNull(advice, "Advice must not be null");
        this.advice = advice;
        this.pointcut = advice.buildSafePointcut();
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    @Override
    public Pointcut getPointcut() {
        return pointcut;
    }

    public String getAspectName() {
        return this.advice.getAspectName();
    }
}
